package com.googlecode.napp.server;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
 
public class GUI extends JFrame implements ActionListener
{
  /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

/**
   * Refresh Button
   */ 
  JButton myButton = new JButton("Refresh");
 
  /**
   * The text area.
   */
  JTextArea myText = new JTextArea(Db.selectTable());
 
  /**
   * The bottom panel which holds button.
   */ 
  JPanel bottomPanel = new JPanel();
 
  /**
   * The top level panel which holds all.
   */
  JPanel holdAll = new JPanel();
 
  /**
   * The constructor.
   */
  public GUI()
  {
    bottomPanel.setLayout(new FlowLayout());
    bottomPanel.add(myButton);
 
    holdAll.setLayout(new BorderLayout());
    holdAll.add(bottomPanel, BorderLayout.SOUTH);
    holdAll.add(myText, BorderLayout.CENTER);
 
    getContentPane().add(holdAll, BorderLayout.CENTER);
 
    myButton.addActionListener(this);
 
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  }
 
  /** Applet Builder   */
  public static void applet()
  {
    GUI myApplication = new GUI();
    myApplication.setLocation(10, 10);
    myApplication.setSize(1600, 300);
    myApplication.setVisible(true);
  }
 
  /**
   * Each non abstract class that implements the ActionListener
   * must have this method.
   * 
   * @param e the action event.
   */
  public void actionPerformed(ActionEvent e)
  {
    if (e.getSource() == myButton)
      myText.setText(Db.selectTable());
    else
      myText.setText("E ...?");
  }
}